package com.ga01.controller;

import com.ga01.entity.EvaMode;
import com.ga01.service.EvaModeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/eva-modes")
public class EvaModeController {

    @Autowired
    private EvaModeService evaModeService;

    @GetMapping
    public List<EvaMode> getAllEvaModes() {
        return evaModeService.list();
    }

    @GetMapping("/{id}")
    public EvaMode getEvaModeById(@PathVariable Integer id) {
        return evaModeService.getById(id);
    }

    @PostMapping
    public boolean addEvaMode(@RequestBody EvaMode evaMode) {
        return evaModeService.save(evaMode);
    }

    @PutMapping
    public boolean updateEvaMode(@RequestBody EvaMode evaMode) {
        return evaModeService.updateById(evaMode);
    }

    @DeleteMapping("/{id}")
    public boolean deleteEvaMode(@PathVariable Integer id) {
        return evaModeService.removeById(id);
    }
}